package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.networkassets.dict;

import com.glsc.ngateway.common.base.domain.mysql.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.List;

/**
 * IT网络资产字典字段项
 * @author xuchang
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_gw_it_net_assets_dict_field set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@SQLDeleteAll(sql = "update t_gw_it_net_assets_dict_field set deleted = UNIX_TIMESTAMP(NOW()) where id=?")
@Table(name = "t_gw_it_net_assets_dict_field", indexes = {@Index(name = "UK_IDCT_CODE", columnList = "dict_code, code, deleted", unique = true),
        @Index(name = "IDX_DICT_CODE", columnList = "dict_code")})
public class ItNetworkAssetsDictField extends BaseEntity {

    private static final long serialVersionUID = -7512274329996238018L;

    @Column(name = "dict_code", columnDefinition = "varchar(128) not null comment '字典code'")
    private String dictCode;

    @Column(name = "describtion", columnDefinition = "varchar(128) not null comment '描述'")
    private String describtion;

    @Column(name = "code", columnDefinition = "varchar(128) not null comment '字段code'")
    private String code;

    @Column(name = "type", columnDefinition = "varchar(16) not null comment '字段类型'")
    private String type;

    @Column(name = "length", columnDefinition = "int comment '字段长度(最长512)'")
    private Integer length;

    /**
     * 值
     */
    @Transient
    private List<ItNetworkAssetsDictFieldValue> valueList;

}
